export default {
  data() {
    return {
      infinitePageIndex: 1,
      infinitePageSize: 10,
      infiniteEnded: false,
      infiniteDisable: false,
      infiniteList: [],
      diyName: undefined,
      diyType: undefined,
      mode: undefined,
    };
  },
  onLoad() {
    //this.getInfiniteList();
  },
  onReachBottom() {
    this.getInfiniteList();
  },
  methods: {
    async getInfiniteList(refresh) {
      if (refresh) {
        this.infinitePageIndex = 1;
        this.infiniteEnded = false;
        this.infiniteList = [];
      }
      if (this.infiniteDisable) return;
      if (this.infiniteEnded) return;
      const { infinitePageIndex, infinitePageSize, diyName, diyType } = this;
      const infiniteList = await this.getInfiniteData(
        infinitePageIndex,
        infinitePageSize,
        diyName,
        diyType
      );
      this.infiniteList.push(...infiniteList);
      this.infinitePageIndex++;
      if (infiniteList.length < infinitePageSize) this.infiniteEnded = true;
    },
  },
};
